package com.dzh.spring.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.dzh.spring.bean.User;
import com.dzh.spring.service.UserService;

@Service
public class UserServiceImpl implements UserService {
	@Override
	public void saveUser() {
		System.out.println("保存 user 成功");

	}

	@Override
	public boolean updateUser() {
		System.out.println("修改 user 成功");
		return true;
	}

	@Override
	public boolean deleteUser() {
		System.out.println("删除 user 成功");
		return true;
	}

	@Override
	public User findUser(int id) {
		User user = new User();
		user.setUserId(id);
		user.setUserName("张三");
		user.setSex("男");
		user.setAge(19);
		return user;
	}

	@Override
	public List<User> queryUsers(int age) {
		List<User> users = new ArrayList<>();
		for(int i =0; i<5 ; i++){
			User user = new User();
			int userid = (int) (Math.random()*10);
			user.setUserId(userid);
			user.setUserName("张三");
			user.setSex("男");
			user.setAge(age);
			users.add(user);
		}
		return users;
	}

}
